import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author jj
 * @date 2019/10/26 15:13
 */
@Slf4j

@Controller
@RequestMapping("/ss")
public class ds {

    @GetMapping("/timer")
    public String doTimer() {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {

            @Override
            public void run() {
                log.info("Timer定时任务启动：" + new Date());

            }
        }, 1000, 1000);//延迟1秒启动，每1秒执行一次
        return "timer";
    }
}
